package model.jgap;

import model.trader.Trader;
import model.trader.Investor;

import org.jgap.Configuration;
import org.jgap.Gene;
import org.jgap.InvalidConfigurationException;
import org.jgap.impl.CompositeGene;
import org.jgap.impl.IntegerGene;

//AM: this is not really needed til we have more parameters..
public class ValueInvestorGene extends CompositeGene implements TraderGene{

	public ValueInvestorGene(Configuration conf) throws InvalidConfigurationException {
		super(conf);
		addGene(new IntegerGene(conf,1,10));
	}
	
	public Trader  getTrader() {
		int daysRequiredToTrade = ((IntegerGene)geneAt(0)).intValue();
		return new Investor(daysRequiredToTrade);
	}
	
//	AMLOW: dodgy copy paste all over the custom gene types..
	protected Gene newGeneInternal() {
	    try {
	      ValueInvestorGene compositeGene = new ValueInvestorGene(getConfiguration());
	      compositeGene.setConstraintChecker(getConstraintChecker());
//	      Gene gene;
//	      int geneSize = m_genes.size();
//	      for (int i = 0; i < geneSize; i++) {
//	        gene = (Gene) m_genes.get(i);
//	        compositeGene.addGene(gene.newGene(), false);
//	      }
	      return compositeGene;
	    }
	    catch (InvalidConfigurationException iex) {
	      throw new IllegalStateException(iex.getMessage());
	    }
	  }
	
}
